package com.billow.net
{
	import flash.net.NetworkInfo;
	import flash.net.NetworkInterface;
	
	public class NetInfo
	{
		/** 返回与此计算机相关联的网络接口的列表 */
		private static var _interfaces:Vector.<NetworkInterface>;
		private static function getInstance():Vector.<NetworkInterface>
		{
			if(!_interfaces)
				_interfaces = NetworkInfo.networkInfo.findInterfaces();
			return _interfaces;
		}
		
		
		/** 本机ip地址 */	
		public static function get localAddress():String 
		{
			var i:int = 0;
			while(i<NetInfo.getInstance().length)
			{
				if(NetInfo.getInstance()[i].addresses.length>0)
					return NetInfo.getInstance()[i].addresses[0].address;
				i++;
			}
			return null;
		}
		
		
		/** 本机mac地址 */		
		public static function get mac():String 
		{
			var i:int = 0;
			while(i<NetInfo.getInstance().length)
			{
				if(NetInfo.getInstance()[i].hardwareAddress.length>10)
					return NetInfo.getInstance()[i].hardwareAddress;
				i++;
			}
			return null;
		}
	}
}